
#include "init.h"
#include "../teximage/teximage.h"

#include "m_menu.h"

////////////////////////////////////////////////////////////////////////////////
struct initial_menu : Menu
{
    initial_menu()
    {
        add_entry( "con|connect" );
        add_entry( "opt|options" );

        add_space(64);

        add_entry( "exit" );
        set_escape_code( "exit" );
    }
};

////////////////////////////////////////////////////////////////////////////////
void bman_net::draw_initial( int key )
{
    static int binit=0;
    static initial_menu menu;

    if(key) {
        token k = menu.onkeypress(key);
        if( k == "opt" )
            CW.gs.state = C_World::GSC_OPTIONS;
        else if( k == "con" )
        {
            CW.gs.state = C_World::GSC_CONNECT;
            opcd e = GW.connect( 0, GW.CW._profile._nick, GW.CW._profile._ip );
            if(e)
                CW.gs.state = C_World::GSC_INITIAL;
        }
        else if( k == "exit" )
            exit(0);
        return;
    }

    if(!binit)
    {
        menu.set_sel_colors( CW._profile._colpri, CW._profile._colsec );
        binit = true;
    }

    SCREEN.clear(0x3f3f3f);
    menu.draw();
}

